package org.itboys.mysql.service;

import org.itboys.mysql.dao.BaseDao;
import org.itboys.mysql.entity.BaseEntity;

/**
 *mysql service 基类
 * Created by weisky on 2017/2/4.
 */
public abstract class BaseService<T extends BaseEntity> {

    protected BaseDao<T> baseDao;

    protected abstract void setBaseDao();

    public void add(T t) {
        setBaseDao();
        baseDao.add(t);
    }

    public T getById(T t){
        setBaseDao();
        return baseDao.getById(t);
    }

    public void updateById(T t) {
        setBaseDao();
        baseDao.updateById(t);
    }

    public void delete(T t) {
        setBaseDao();
        baseDao.delete(t);
    }

    public T get(T t) {
        setBaseDao();
        t = baseDao.get(t);
        return t;
    }
}
